// 创建实例
import axios from 'axios';
axios.defaults.headers['Content-Type'] = 'application/json;charset=UTF-8';
const env = process.env.NODE_ENV;
const service = axios.create({
  // 公共请求头
  baseURL: env === 'development'? '/': window.SUPER_GIS_SPACE.requestBaseUrl,
  // 请求超时时间
  timeout: 30000,
  responseType: 'json',
  withCredentials: false
})
// 相关拦截器处理
service.interceptors.request.use(config => {
  return config
}, (error) => {
  return Promise.reject(error)
})

service.interceptors.response.use((response) => {
  return response.data
}, (error) => {
  return {
    success: false,
    message: error.message
  }
  // return Promise.reject(error)
})

// 导出实例
export default service